

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
    <style>
    /* base */
    html,
    body,
    .container {
      width: 100%;
      height: 100%;
    }

    a,
    a:link,
    a:visited {
      text-decoration: none;
      color: inherit;
    }

    ul {
      list-style: none;
    }

    *,
    ::before,
    ::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    *:focus {
      outline: 0;
    }

    .container {
      display: flex;
      padding-top: 20px;
    }

    /* Nav */
    .container .doc-nav {
      position: fixed;
      height: 100%;
      margin: 0 30px 0 40px;
      width: 280px;
    }

    .doc-nav .nav-header {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      background-color: rgb(240, 241, 242);
      height: 40px;
      padding: 16px;
      font-size: 18px;
      font-weight: 500;
      color: rgb(62, 64, 66);
      cursor: pointer;
    }

    .doc-nav .nav-content {
      height: calc(100% - 40px);
      overflow-y: auto;
      color: rgb(32, 34, 36);
    }

    .doc-nav .nav-content .nav-list,
    .doc-nav .nav-content .nav-sub-list {
      line-height: 1.5rem;
    }

    .doc-nav .nav-content .nav-label {
      display: inline-block;
      position: relative;
      padding: 2px 0 2px 20px;
      margin-bottom: 4px;
    }

    .doc-nav .nav-content .nav-sub-label {
      position: relative;
      padding: 2px 0 2px 40px;
      font-size: 14px;
    }

    .doc-nav .nav-content .nav-sub-label:hover {
      text-decoration: underline;
    }

    .doc-nav .nav-content .nav-list .nav-label.group::before {
      border-bottom: 0.25rem solid transparent;
      border-left: 0.25rem solid #6e7072;
      border-right: 0;
      border-top: 0.25rem solid transparent;
      content: '';
      display: block;
      height: 0;
      left: 0.5rem;
      position: absolute;
      top: 0.625rem;
      transition: transform 0.1s linear;
      width: 0;
    }

    .doc-nav .nav-content .nav-list .nav-label.group.active::before {
      transform: rotate(90deg);
    }

    /* doc content */
    .container .doc-content {
      position: fixed;
      height: 100%;
      width: calc(100% - 80px - 40px - 30px - 240px);
      right: 0%;
      overflow-y: auto;
    }

    .doc-title {
      border-bottom: 1px solid #dcdee0;
      font-size: 22px;
      margin: 8px 0 0;
      padding-bottom: 16px;
    }

    .doc-content h3 {
      font-size: 24px;
      font-weight: 600;
      margin: 24px 0;
    }

    .doc-content h4 {
      font-size: 22px;
      font-weight: 500;
      margin: 30px 0 8px;
    }

    .doc-content h4 span {
      color: #007d9c;
    }

    .doc-content .doc-declare {
      background-color: #fafafa;
      border-radius: 5px;
      border: 1px solid #ccc;
      font-size: 14px;
      overflow-x: auto;
      padding: 10px;
      tab-size: 4;
      line-height: 20px;
    }

    .doc-content .doc-comment {
      font-size: 16px;
      margin: 16px 0;
      line-height: 24px;
      word-break: break-word;
    }
  </style>

</head>
<body>
  <div class="container">
    <div class="doc-nav">
      <a href="#Documentation" class="nav-header">Documentation</a>
      <nav class="nav-content">
        <ul class="nav-list">
          <li>
            <a href="#includes" class="nav-label">Includes</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#config.h" class="nav-sub-label">config.h</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_CONFIG_FILE" class="nav-sub-label">MBEDTLS_CONFIG_FILE</a>
              </li>
      

              <li>
                <a href="#stdint.h" class="nav-sub-label">stdint.h</a>
              </li>
      

              <li>
                <a href="#stddef.h" class="nav-sub-label">stddef.h</a>
              </li>
      

              <li>
                <a href="#chacha20_alt.h" class="nav-sub-label">chacha20_alt.h</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#macros" class="nav-label">Macros</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#MBEDTLS_CHACHA20_H" class="nav-sub-label">MBEDTLS_CHACHA20_H</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA" class="nav-sub-label">MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE" class="nav-sub-label">MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE</a>
              </li>
      

              <li>
                <a href="#MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED" class="nav-sub-label">MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#functions" class="nav-label">Functions</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#mbedtls_chacha20_init" class="nav-sub-label">mbedtls_chacha20_init</a>
              </li>
      

              <li>
                <a href="#mbedtls_chacha20_free" class="nav-sub-label">mbedtls_chacha20_free</a>
              </li>
      

              <li>
                <a href="#mbedtls_chacha20_setkey" class="nav-sub-label">mbedtls_chacha20_setkey</a>
              </li>
      

              <li>
                <a href="#mbedtls_chacha20_starts" class="nav-sub-label">mbedtls_chacha20_starts</a>
              </li>
      

              <li>
                <a href="#mbedtls_chacha20_update" class="nav-sub-label">mbedtls_chacha20_update</a>
              </li>
      

              <li>
                <a href="#mbedtls_chacha20_crypt" class="nav-sub-label">mbedtls_chacha20_crypt</a>
              </li>
      

              <li>
                <a href="#mbedtls_chacha20_self_test" class="nav-sub-label">mbedtls_chacha20_self_test</a>
              </li>
      
            </ul>
            
          </li>
          <li>
            <a href="#vars" class="nav-label">Vars</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#consts" class="nav-label">Consts</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#types" class="nav-label">Types</a>
            
            <ul class="nav-sub-list">
            
            </ul>
            
          </li>
          <li>
            <a href="#typedefs" class="nav-label">Typedefs</a>
             
            <ul class="nav-sub-list">

              <li>
                <a href="#
mbedtls_chacha20_context;
" class="nav-sub-label">
mbedtls_chacha20_context;
</a>
              </li>
      
            </ul>
            
          </li>
        </ul>
      </nav>
    </div>
    <div class="doc-content">
      <h2 id="Documentation" class="doc-title">Documentation</h2>
      <h3 id="includes">Includes</h3>
      

      <h4 id="config.h"><span>config.h</span></h4>
      <pre class="doc-declare"><code>#include "config.h"
</code></pre>
      <pre class="doc-comment">#include "config.h"
</pre>

      <h4 id="MBEDTLS_CONFIG_FILE"><span>MBEDTLS_CONFIG_FILE</span></h4>
      <pre class="doc-declare"><code>#include MBEDTLS_CONFIG_FILE
</code></pre>
      <pre class="doc-comment">#include MBEDTLS_CONFIG_FILE
</pre>

      <h4 id="stdint.h"><span>stdint.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;stdint.h&gt;
</code></pre>
      <pre class="doc-comment">#include <stdint.h>
</pre>

      <h4 id="stddef.h"><span>stddef.h</span></h4>
      <pre class="doc-declare"><code>#include &lt;stddef.h&gt;
</code></pre>
      <pre class="doc-comment">#include <stddef.h>
</pre>

      <h4 id="chacha20_alt.h"><span>chacha20_alt.h</span></h4>
      <pre class="doc-declare"><code>#include "chacha20_alt.h"
</code></pre>
      <pre class="doc-comment">#include "chacha20_alt.h"
</pre>
      <h3 id="macros">Macros</h3>
      

      <h4 id="MBEDTLS_CHACHA20_H">Marco <span>MBEDTLS_CHACHA20_H</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_CHACHA20_H
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA">Marco <span>MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA        -81 /**< Invalid input parameter(s). */
</code></pre>
      <pre class="doc-comment"></pre>

      <h4 id="MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE">Marco <span>MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE   -83 /**< Feature not available. For example, s part of the API is not implemented. */
</code></pre>
      <pre class="doc-comment">/* MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE is deprecated and should not be
 * used. */</pre>

      <h4 id="MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED">Marco <span>MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED</span></h4>
      <pre class="doc-declare"><code>#define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED       -85 /**< Chacha20 hardware accelerator failed. */
</code></pre>
      <pre class="doc-comment">/* MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED is deprecated and should not be used.
 */</pre>
      <h3 id="functions">Functions</h3>
      

      <h4 id="mbedtls_chacha20_init">Func <span>mbedtls_chacha20_init</span></h4>
      <pre class="doc-declare"><code>void mbedtls_chacha20_init( mbedtls_chacha20_context *ctx );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function initializes the specified ChaCha20 context.
 *
 *                  It must be the first API called before using
 *                  the context.
 *
 *                  It is usually followed by calls to
 *                  \c mbedtls_chacha20_setkey() and
 *                  \c mbedtls_chacha20_starts(), then one or more calls to
 *                  to \c mbedtls_chacha20_update(), and finally to
 *                  \c mbedtls_chacha20_free().
 *
 * \param ctx       The ChaCha20 context to initialize.
 *                  This must not be \c NULL.
 */</pre>

      <h4 id="mbedtls_chacha20_free">Func <span>mbedtls_chacha20_free</span></h4>
      <pre class="doc-declare"><code>void mbedtls_chacha20_free( mbedtls_chacha20_context *ctx );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function releases and clears the specified
 *                  ChaCha20 context.
 *
 * \param ctx       The ChaCha20 context to clear. This may be \c NULL,
 *                  in which case this function is a no-op. If it is not
 *                  \c NULL, it must point to an initialized context.
 *
 */</pre>

      <h4 id="mbedtls_chacha20_setkey">Func <span>mbedtls_chacha20_setkey</span></h4>
      <pre class="doc-declare"><code>int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx,
                            const unsigned char key[32] );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function sets the encryption/decryption key.
 *
 * \note            After using this function, you must also call
 *                  \c mbedtls_chacha20_starts() to set a nonce before you
 *                  start encrypting/decrypting data with
 *                  \c mbedtls_chacha_update().
 *
 * \param ctx       The ChaCha20 context to which the key should be bound.
 *                  It must be initialized.
 * \param key       The encryption/decryption key. This must be \c 32 Bytes
 *                  in length.
 *
 * \return          \c 0 on success.
 * \return          #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA if ctx or key is NULL.
 */</pre>

      <h4 id="mbedtls_chacha20_starts">Func <span>mbedtls_chacha20_starts</span></h4>
      <pre class="doc-declare"><code>int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx,
                            const unsigned char nonce[12],
                            uint32_t counter );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function sets the nonce and initial counter value.
 *
 * \note            A ChaCha20 context can be re-used with the same key by
 *                  calling this function to change the nonce.
 *
 * \warning         You must never use the same nonce twice with the same key.
 *                  This would void any confidentiality guarantees for the
 *                  messages encrypted with the same nonce and key.
 *
 * \param ctx       The ChaCha20 context to which the nonce should be bound.
 *                  It must be initialized and bound to a key.
 * \param nonce     The nonce. This must be \c 12 Bytes in size.
 * \param counter   The initial counter value. This is usually \c 0.
 *
 * \return          \c 0 on success.
 * \return          #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA if ctx or nonce is
 *                  NULL.
 */</pre>

      <h4 id="mbedtls_chacha20_update">Func <span>mbedtls_chacha20_update</span></h4>
      <pre class="doc-declare"><code>int mbedtls_chacha20_update( mbedtls_chacha20_context *ctx,
                            size_t size,
                            const unsigned char *input,
                            unsigned char *output );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function encrypts or decrypts data.
 *
 *                  Since ChaCha20 is a stream cipher, the same operation is
 *                  used for encrypting and decrypting data.
 *
 * \note            The \p input and \p output pointers must either be equal or
 *                  point to non-overlapping buffers.
 *
 * \note            \c mbedtls_chacha20_setkey() and
 *                  \c mbedtls_chacha20_starts() must be called at least once
 *                  to setup the context before this function can be called.
 *
 * \note            This function can be called multiple times in a row in
 *                  order to encrypt of decrypt data piecewise with the same
 *                  key and nonce.
 *
 * \param ctx       The ChaCha20 context to use for encryption or decryption.
 *                  It must be initialized and bound to a key and nonce.
 * \param size      The length of the input data in Bytes.
 * \param input     The buffer holding the input data.
 *                  This pointer can be \c NULL if `size == 0`.
 * \param output    The buffer holding the output data.
 *                  This must be able to hold \p size Bytes.
 *                  This pointer can be \c NULL if `size == 0`.
 *
 * \return          \c 0 on success.
 * \return          A negative error code on failure.
 */</pre>

      <h4 id="mbedtls_chacha20_crypt">Func <span>mbedtls_chacha20_crypt</span></h4>
      <pre class="doc-declare"><code>int mbedtls_chacha20_crypt( const unsigned char key[32],
                           const unsigned char nonce[12],
                           uint32_t counter,
                           size_t size,
                           const unsigned char* input,
                           unsigned char* output );</code></pre>
      <pre class="doc-comment">/**
 * \brief           This function encrypts or decrypts data with ChaCha20 and
 *                  the given key and nonce.
 *
 *                  Since ChaCha20 is a stream cipher, the same operation is
 *                  used for encrypting and decrypting data.
 *
 * \warning         You must never use the same (key, nonce) pair more than
 *                  once. This would void any confidentiality guarantees for
 *                  the messages encrypted with the same nonce and key.
 *
 * \note            The \p input and \p output pointers must either be equal or
 *                  point to non-overlapping buffers.
 *
 * \param key       The encryption/decryption key.
 *                  This must be \c 32 Bytes in length.
 * \param nonce     The nonce. This must be \c 12 Bytes in size.
 * \param counter   The initial counter value. This is usually \c 0.
 * \param size      The length of the input data in Bytes.
 * \param input     The buffer holding the input data.
 *                  This pointer can be \c NULL if `size == 0`.
 * \param output    The buffer holding the output data.
 *                  This must be able to hold \p size Bytes.
 *                  This pointer can be \c NULL if `size == 0`.
 *
 * \return          \c 0 on success.
 * \return          A negative error code on failure.
 */</pre>

      <h4 id="mbedtls_chacha20_self_test">Func <span>mbedtls_chacha20_self_test</span></h4>
      <pre class="doc-declare"><code>int mbedtls_chacha20_self_test( int verbose );</code></pre>
      <pre class="doc-comment">/**
 * \brief           The ChaCha20 checkup routine.
 *
 * \return          \c 0 on success.
 * \return          \c 1 on failure.
 */</pre>
      <h3 id="vars">Vars</h3>
      
      <h3 id="consts">Consts</h3>
      
      <h3 id="types">Types</h3>
      
      <h3 id="typedefs">Typedefs</h3>
      

      <h4 id="
mbedtls_chacha20_context;
">Typedef <span>
mbedtls_chacha20_context;
</span></h4>
      <pre class="doc-declare"><code>typedef struct mbedtls_chacha20_context
{
   uint32_t state[16];         /*! The state (before round operations). */
   uint8_t keystream8[64];    /*! Leftover keystream bytes. */
   size_t keystream_bytes_used; /*! Number of keystream bytes already used. */
}
mbedtls_chacha20_context;
</code></pre>
      <pre class="doc-comment"></pre>
    </div>
  </body>
</html>
            